$(function (){
    //医院事件改变监听
    $("#deliveryHospital").change(loadmidwife);

    loadmidwife();

});

//加载接生员
function loadmidwife(){
    //取得医院ID
    var hospitalId=  $("#deliveryHospital").val();
    //使用ajax
    $.ajax({
        type:'get',
        url:'/hr/hospital/midwife',
        data:"hospitalId="+hospitalId,
        dataType:"json",
        success:function (res){
            if (res.code===1){
                let midwifeSelect= $("#midwifeId");

                midwifeSelect.empty();

                let  arr=res.data;
                let midwifeId = $("#_midwifeId").val();

                for(let d of arr){
                    let str;
                    if (midwifeId == d.midwifeId){
                        str=`<option value="${d.midwifeId}" selected >${d.midwifeName}</option>`
                    } else {
                        str=`<option value="${d.midwifeId}" >${d.midwifeName}</option>`
                    }

                    midwifeSelect.append(str);
                }

            }
        }
    });
}